#ifndef ZDATA_MANAGER_H_
#define ZDATA_MANAGER_H_

#include "../Common/GlobalDefines.h"
#include "../Common/ZSingleton.h"
#include "../Scene/Mesh3D.h"
#include <Scene/PointCloud.h>
//#include <Scene/ZImage.h>
#include "ZImageManager.h"

#include <vector>
#include <map>

GLOBAL_NAMESPACE_BEGIN

class DataManager : public Singleton< DataManager >
{
public:
    typedef std::vector<MeshSpace::Mesh3D*> MeshList;
    typedef std::vector<MeshSpace::PointCloud*> PointCloudList;
    //typedef std::vector<ImageSpace::Image*> ImageList;
    typedef std::map<std::string, ImageSpace::Image*> ImageContainer;
    typedef std::map<int, std::string> ImageNameContainder;
    typedef ImageContainer::iterator ImageIterator;

public:
    DataManager();
    ~DataManager();

    void init();
    void clear();

    void addMesh(MeshSpace::Mesh3D *mesh);
    void addPointCloud(MeshSpace::PointCloud* pc);
    void addImage(ImageSpace::Image* ima, int id=-1);

    void removePointCloud(MeshSpace::PointCloud* pc);
    void removeMesh(MeshSpace::Mesh3D *mesh);
    void removeImage(ImageSpace::Image* ima);

    void clearImageData();

    size_t getImageCount();
    size_t getDefaultImageCount();

    MeshSpace::Mesh3D* getMesh();
    MeshSpace::PointCloud* getPointCloud();
    ImageSpace::Image* getImageById(int idx=0);
    ImageSpace::Image* readImage(const char* imaName, int id=-1);

    ImageIterator imageBeginIterator();
    ImageIterator imageEndIterator();

private:
    void destroy();

private:
    MeshList        meshes_;
    PointCloudList  pointClouds_;
    //ImageList       images_;
    //ImageManager    imageManager_;
    ImageContainer images_;
    ImageNameContainder imageNames_;

    int nDefaultImageCount_;
};

GLOBAL_NAMESPACE_END

#endif//ZDATA_MANAGER_H_